/*************************************************************************
	> File Name: ./include/CentralCache.h
	> Author: zq
	> Mail: zhouquan1511@163.com 
	> Created Time: Thu 27 Apr 2023 07:19:34 PM CST
 ************************************************************************/
#pragma once

#include "Common.h"

class CentralCache {
	private:
		static CentralCache _sInst;
		CentralCache() {}
		CentralCache(const CentralCache&);
		
		SpanList _spanLists[NFREELISTS];
	public:
		static CentralCache* _GetInstance() {
			return &_sInst;
		}
		
		//在相应哈希桶上获取一个非空Span
		Span* GetOneSpan(SpanList &spanList, size_t size);

		//从central cache获取一定数量的对象给thread cache
		size_t FetchRangeObj(void *&start, void *&end,
							size_t n, size_t size);

		//上层threadCache将一定数量的对象归还给centralCache
		void ReleaseListToSpans(void *start, size_t size);
};
